<template>
  <div class="home">
    <Banner />
    <div class="content">
      <Menu @menu-change="handleMenuChange" />
      <component :is="currentComponent" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { shallowRef } from "vue";
import Banner from "../components/Banner.vue";
import Menu from "../components/Menu.vue";
import Phone from "../components/Phone.vue";
import Laptop from "../components/Laptop.vue";
import Accessory from "../components/Accessory.vue";

const currentComponent = shallowRef(Phone); // 初始显示手机专区

const handleMenuChange = (menuId: string) => {
  if (menuId === "phone") {
    currentComponent.value = Phone;
  } else if (menuId === "laptop") {
    currentComponent.value = Laptop;
  } else if (menuId === "accessory") {
    currentComponent.value = Accessory;
  }
};
</script>

<style scoped>
.home {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.content {
  display: flex;
  flex: 1;
}
</style>
